#include <iostream>
#include <stdio.h>

using namespace std;

char a[3] = {'a','b','c'};

void f(int n,char a,char b,char c){
    if(n == 1){
        printf("%c->%d->%c\n",a,n,b);
    }
    else{
       f(n-1,a,c,b);
       printf("%c->%d->%c\n",a,n,b);
       f(n-1,c,b,a);
    }
}

int main() {
    int n;
    cin >> n;
    for(int i = 0; i< 3;i++){
        cin >> a[i];
    }
    f(n,a[0],a[1],a[2]);
    return 0;
}